package com.zq.assistant.ui.widget.recyclerview.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.zq.assistant.ui.widget.recyclerview.RecyclerViewHolder;

import java.util.List;

/**
 * Created by zhangqiang on 17-7-4.
 */

public abstract class SingleHeaderFooterAdapter<T> extends BaseObjectRecyclerAdapter<T,RecyclerViewHolder> {

    private int headerLayoutID;
    private int footerLayoutID;

    public SingleHeaderFooterAdapter(List<T> dataList, Context context, int headerLayoutID, int footerLayoutID) {
        super(dataList, context);
        this.headerLayoutID = headerLayoutID;
        this.footerLayoutID = footerLayoutID;
    }

    @Override
    public final RecyclerViewHolder onCreateHeaderViewHolder(ViewGroup parent, int viewType) {
        return RecyclerViewHolder.create(context,headerLayoutID,parent);
    }

    @Override
    public final RecyclerViewHolder onCreateFooterViewHolder(ViewGroup parent, int viewType) {
        return RecyclerViewHolder.create(context,footerLayoutID,parent);
    }

    @Override
    public final int getHeaderItemCount() {

        if(headerLayoutID > 0){
            return 1;
        }
        return super.getHeaderItemCount();
    }

    @Override
    public final int getFooterItemCount() {

        if(footerLayoutID > 0){
            return 1;
        }
        return super.getFooterItemCount();
    }
}
